package net.wendal.base.type;

/**
 * Created by y on 2017/2/6.
 */
public class ToyTest {


    public static void main(String[] args) {

        Class cc = null;

        try {
            cc = Class.forName("net.wendal.base.type.FactoryToy");
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
            System.exit(1);
        }

        printInfo(cc);

        for (Class cla : cc.getInterfaces()) {
            printInfo(cla);
        }

        Class scla = cc.getSuperclass();

        Object obj = null;

        try {
            obj = scla.newInstance();
        } catch (InstantiationException e) {
            e.printStackTrace();
            System.exit(1);
        } catch (IllegalAccessException e) {
            e.printStackTrace();
            System.exit(1);
        }

        printInfo(obj.getClass());


    }

    static void printInfo(Class cc) {
        System.out.println("Class Name: " + cc.getName() + " is interface? [" + cc.isInterface() + "]");
        System.out.println("simple Name: " + cc.getSimpleName());
        System.out.println("Canonical Name: " + cc.getCanonicalName());
    }

}

    interface HasBatteries {}
    interface Waterproof {}
    interface Shoots {}

    class Toy {
        Toy() {}
        Toy(int i) {}
    }

    class FactoryToy extends Toy implements HasBatteries, Waterproof, Shoots{

        FactoryToy() {
            super(1);
        }
    }
